package com.runjian.rundo.iot.agent.iec104.parser.frame.control.system;

import com.runjian.rundo.iot.agent.iec104.parser.frame.ASDUFrame;
import com.runjian.rundo.iot.agent.iec104.parser.frame.InfoElement;

import cn.hutool.core.util.ArrayUtil;
import cn.hutool.core.util.ByteUtil;
import lombok.Getter;
import lombok.Setter;

/**
 * C_RD_NA_1(0x66, "读单个参数命令(参数设置)"),
 *
 * @author CaoQingHua
 */
@Getter
@Setter
public class C_RD_NA_1 extends ASDUFrame {

    @Override
    public void analysisInfo(byte[] msg) {
        this.addInfoElement(InfoElement.<Float>builder().address(ByteUtil.bytesToInt(new byte[] {msg[12], msg[13], msg[14], 0x00}))
            .value(Float.intBitsToFloat(ByteUtil.bytesToInt(ArrayUtil.sub(msg, 15, 19)))).build());
    }

}
